#include <SDL.h>



/*
 * Return the pixel value at (x, y)
 * NOTE: The surface must be locked before calling this!
 */
void getpixel(SDL_Surface *surface, int x, int y, int *R,int *G,int *B)
{
    Uint8 *colors;
    Uint32 pixel;
    int bpp = surface->format->BytesPerPixel;
    /* Here p is the address to the pixel we want to retrieve */
    Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;


    switch(bpp)
    {
    case 1:
        pixel= *p;


    case 2:
        pixel= *(Uint16 *)p;


    case 3:
        if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
            pixel= p[0] << 16 | p[1] << 8 | p[2];
        else
            pixel= p[0] | p[1] << 8 | p[2] << 16;


    case 4:
        pixel= *(Uint32 *)p;




    }


    colors = (Uint8*)&pixel;


        *B=colors[0];
        *G=colors[1];
        *R=colors[2];
       // alpha=colors[3];


}
int collisionBackground(SDL_Surface * surface,int x,int y)
{
    int R,G,B;
   // recuperer  R G et B

   getpixel(surface,x,y,&R,&G,&B);

   if(R == 255 && G == 255 && B == 255)
    return(1);
   else
    return(0);
}
